from flask import Blueprint, jsonify

# 创建蓝图
bp = Blueprint("withstand", __name__, url_prefix="/withstand")


@bp.get("/data/list")
def get_dict_list():
    """
    获取用户信息接口
    返回用户的基本信息、角色和按钮权限
    """
    response_data = {
        "total": 58,
        "rows": [
            {
                "dictCode": 30,
                "dictSort": 0,
                "dictLabel": "dict.sys_grant_type.password",
                "dictValue": "password",
                "dictType": "sys_grant_type",
                "cssClass": "el-check-tag",
                "listClass": "default",
                "isDefault": "N",
                "remark": "密码认证",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": 31,
                "dictSort": 0,
                "dictLabel": "dict.sys_grant_type.sms",
                "dictValue": "sms",
                "dictType": "sys_grant_type",
                "cssClass": "el-check-tag",
                "listClass": "default",
                "isDefault": "N",
                "remark": "短信认证",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": 32,
                "dictSort": 0,
                "dictLabel": "dict.sys_grant_type.email",
                "dictValue": "email",
                "dictType": "sys_grant_type",
                "cssClass": "el-check-tag",
                "listClass": "default",
                "isDefault": "N",
                "remark": "邮件认证",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": 33,
                "dictSort": 0,
                "dictLabel": "dict.sys_grant_type.miniapp",
                "dictValue": "xcx",
                "dictType": "sys_grant_type",
                "cssClass": "el-check-tag",
                "listClass": "default",
                "isDefault": "N",
                "remark": "小程序认证",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": 34,
                "dictSort": 0,
                "dictLabel": "dict.sys_grant_type.social",
                "dictValue": "social",
                "dictType": "sys_grant_type",
                "cssClass": "el-check-tag",
                "listClass": "default",
                "isDefault": "N",
                "remark": "三方登录认证",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": 35,
                "dictSort": 0,
                "dictLabel": "dict.sys_device_type.pc",
                "dictValue": "pc",
                "dictType": "sys_device_type",
                "cssClass": "",
                "listClass": "default",
                "isDefault": "N",
                "remark": "PC",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": 36,
                "dictSort": 0,
                "dictLabel": "dict.sys_device_type.android",
                "dictValue": "android",
                "dictType": "sys_device_type",
                "cssClass": "",
                "listClass": "default",
                "isDefault": "N",
                "remark": "安卓",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": 37,
                "dictSort": 0,
                "dictLabel": "dict.sys_device_type.ios",
                "dictValue": "ios",
                "dictType": "sys_device_type",
                "cssClass": "",
                "listClass": "default",
                "isDefault": "N",
                "remark": "iOS",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": 38,
                "dictSort": 0,
                "dictLabel": "dict.sys_device_type.miniapp",
                "dictValue": "xcx",
                "dictType": "sys_device_type",
                "cssClass": "",
                "listClass": "default",
                "isDefault": "N",
                "remark": "小程序",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": "1957973448617619457",
                "dictSort": 0,
                "dictLabel": "哈哈",
                "dictValue": "hh",
                "dictType": "wf_task_status",
                "cssClass": "",
                "listClass": "primary",
                "isDefault": "N",
                "remark": "",
                "createTime": "2025-08-20 09:10:22",
            },
        ],
        "code": 200,
        "msg": "查询成功",
    }

    return jsonify(response_data)


@bp.get("/type/optionselect")
def get_dict_type_optionselect():
    """
    获取字典类型下拉列表
    """
    response_data = {
        "code": 200,
        "msg": "操作成功",
        "data": [
            {
                "dictId": "1957703548122177537",
                "dictName": "丽水统筹区",
                "dictType": "sys_area_code",
                "remark": "丽水统筹区列表",
                "createTime": "2025-08-19 15:17:53",
            },
            {
                "dictId": 10,
                "dictName": "系统状态",
                "dictType": "sys_common_status",
                "remark": "登录状态列表",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": 12,
                "dictName": "设备类型",
                "dictType": "sys_device_type",
                "remark": "客户端设备类型",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": 11,
                "dictName": "授权类型",
                "dictType": "sys_grant_type",
                "remark": "认证授权类型",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": 3,
                "dictName": "系统开关",
                "dictType": "sys_normal_disable",
                "remark": "系统开关列表",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": 8,
                "dictName": "通知状态",
                "dictType": "sys_notice_status",
                "remark": "通知状态列表",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": 7,
                "dictName": "通知类型",
                "dictType": "sys_notice_type",
                "remark": "通知类型列表",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": 9,
                "dictName": "操作类型",
                "dictType": "sys_oper_type",
                "remark": "操作类型列表",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": 2,
                "dictName": "菜单状态",
                "dictType": "sys_show_hide",
                "remark": "菜单状态列表",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": 1,
                "dictName": "用户性别",
                "dictType": "sys_user_sex",
                "remark": "用户性别列表",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": 6,
                "dictName": "系统是否",
                "dictType": "sys_yes_no",
                "remark": "系统是否列表",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictId": "1957717578677366786",
                "dictName": "测试字典长度看看前端显示",
                "dictType": "test_dict_length",
                "remark": "",
                "createTime": "2025-08-19 16:13:38",
            },
            {
                "dictId": 13,
                "dictName": "业务状态",
                "dictType": "wf_business_status",
                "remark": "业务状态列表",
                "createTime": "2025-06-03 06:14:39",
            },
            {
                "dictId": 14,
                "dictName": "表单类型",
                "dictType": "wf_form_type",
                "remark": "表单类型列表",
                "createTime": "2025-06-03 06:14:39",
            },
            {
                "dictId": 15,
                "dictName": "任务状态",
                "dictType": "wf_task_status",
                "remark": "任务状态",
                "createTime": "2025-06-03 06:14:39",
            },
        ],
    }

    return jsonify(response_data)


@bp.get("/data/type/<dict_type>")
def get_dict_data_type(dict_type):
    """
    获取字典数据列表
    """
    print(dict_type)

    response_data = {
        "code": 200,
        "msg": "操作成功",
        "data": [
            {
                "dictCode": 12,
                "dictSort": 1,
                "dictLabel": "dict.sys_yes_no.yes",
                "dictValue": "Y",
                "dictType": "sys_yes_no",
                "cssClass": "",
                "listClass": "primary",
                "isDefault": "Y",
                "remark": "系统默认是",
                "createTime": "2025-05-21 02:26:43",
            },
            {
                "dictCode": 13,
                "dictSort": 2,
                "dictLabel": "dict.sys_yes_no.no",
                "dictValue": "N",
                "dictType": "sys_yes_no",
                "cssClass": "",
                "listClass": "error",
                "isDefault": "N",
                "remark": "系统默认否",
                "createTime": "2025-05-21 02:26:43",
            },
        ],
    }

    return jsonify(response_data)
